<template>
  <a-card :bordered="false">
    <div style="margin:10px">{{$t('账户编码')}}：{{account.code}}</div>
    <div style="margin:10px">{{$t('账户名称')}}：{{account.name}}</div>
    <div style="margin:10px">{{$t('账户余额')}}：{{account.balance}}</div>
    <div style="margin:10px">{{$t('预警值')}}：{{account.warnValue}}</div>
    <a-button v-has="'GiftTransController:edit'" type="primary" style="margin-left: 10px" @click="charge">{{$t('充值')}}</a-button>
    <a-button v-has="'YardAccountController:export'" type="primary" style="margin-left: 10px" @click="accountFlow">{{$t('账户流水')}}</a-button>
    <account-flow-modal ref="modalForm" :account-id="account.id"/>
    <recharge-modal ref="rechargeModal" @ok="handelRechargeOk"></recharge-modal>
  </a-card>
</template>

<script>
import { getAction } from '@/api/manage'
import accountFlowModal from './modules/AccountFlowModal'
import RechargeModal from './modules/RechargeModal'
import Vue from 'vue'

export default {
  name: 'StoredValueAccount',
  components: {
    accountFlowModal,
    RechargeModal
  },
  data() {
    return {
      description: '预储值账户',
      account: {}
    }

  },
  created() {
    this.getAccount()
  },
  methods: {
    initDictConfig() {},
    getAccount() {
      getAction('/gift/account',{}).then((res) => {
        if (res.success) {
          if (res.result.records.length > 0) {
            this.account = res.result.records[0]
          }
        }else{
          this.$message.warning(res.message)
        }
      })
    },
    // charge() {
    //   this.$message.warning(this.$t('正在开发中~'))
    // },
    charge(record){
      let that=this
      that.$refs.rechargeModal.show(that.account);
    },
    accountFlow() {
      this.$refs.modalForm.loadData(1);
      this.$refs.modalForm.title = this.$t('账户流水');
      this.$refs.modalForm.visible = true;
    },
    handelRechargeOk(){
      this.getAccount()
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>